﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Script.Serialization;

namespace DrillingTrack3D.Utils
{
    public class JsonUtil
    {
        /// <summary>
        /// 转换对象为JSON格式数据
        /// </summary>
        /// <typeparam name="T">类</typeparam>
        /// <param name="obj">对象</param>
        /// <returns>字符格式的JSON数据</returns>
        public static string ToJson(object obj)
        {
            var st = new StringBuilder();
            var jss = new JavaScriptSerializer();
            jss.Serialize(obj, st);

            return st.ToString();
        }

    }
}